package com.cili.learning.springbootwebsocket.config;

import com.cili.learning.springbootwebsocket.interceptor.MyWebSocketInterceptor;
import com.cili.learning.springbootwebsocket.websockethandler.MyWebSocketHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author 码头薯条Pro
 * @date 2025/7/14 23:35
 * <p></p>
 * <p>
 * 视频讲解链接：
 * <p>
 * 题解链接：
 * <p>
 * 题目链接：
 */

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new MyWebSocketHandler(), "/ws/test")
                .addInterceptors(new MyWebSocketInterceptor())
                .setAllowedOrigins("*");
    }

}
